<script lang="ts" setup>
import { useRouter } from "vue-router"
import { useAppStore } from "@/store/modules/app.ts"
import { useUserStore } from "@/store/modules/user"
import { UserFilled } from "@element-plus/icons-vue"

const router = useRouter()
const appStore = useAppStore()
const userStore = useUserStore()



/** 切换侧边栏 */
const toggleSidebar = () => {
  appStore.toggleSidebar(false)
}

/** 登出 */
const logout = () => {
  userStore.logout()
  router.push("/login")
}
</script>

<template>
  <el-dropdown placement="right" class="right-menu-item admin">
    <div class="right-menu-avatar">
      <el-avatar :icon="UserFilled" :size="30" />
    </div>
    <template #dropdown>
      <el-dropdown-menu>
        <a target="_blank" href="javascript:;">
          <el-dropdown-item>官网首页</el-dropdown-item>
        </a>
        <a target="_blank" href="javascript:;">
          <el-dropdown-item>会员中心</el-dropdown-item>
        </a>
        <el-dropdown-item divided @click="logout">
          <span style="display: block">退出登录</span>
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<style lang="scss" scoped>
.admin {
  position: absolute;
  bottom: 0px;
  left: 50%;
  transform: translate(-50%, -50%);
}

.navigation-bar {
  height: var(--v3-navigationbar-height);
  overflow: hidden;
  background: var(--v3-header-bg-color);
  display: flex;
  justify-content: space-between;



  .right-menu {
    // margin-right: 10px;
    height: 100%;
    display: flex;
    align-items: center;
    color: #606266;

    .right-menu-item {
      padding: 0 10px;
      cursor: pointer;

      .right-menu-avatar {
        display: flex;
        align-items: center;

        .el-avatar {
          margin-right: 10px;
        }

        span {
          font-size: 16px;
        }
      }
    }
  }
}
</style>
